﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MMK.Paket_Tracker.Runtime.Helper;

namespace MMK.Paket_Tracker.GUI.PTMessageBox
{
    /// <summary>
    /// Interaction logic for PTMessageBox.xaml
    /// </summary>
    public partial class PTMessageBox : Window
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PTMessageBox"/> class.
        /// </summary>
        public PTMessageBox(UserControl owner)
        {
            InitializeComponent();
            FrameworkElement parent = WPFTools.FindParentByName(owner, "StartupWindow");
            foreach (var item in parent.Resources.MergedDictionaries)
            {
                this.Resources.MergedDictionaries.Add(item);
            }
        }

        /// <summary>
        /// Sets the error text.
        /// </summary>
        /// <value>
        /// The error text.
        /// </value>
        public Object ErrorText
        {
            set
            {
                if (value.GetType() == typeof(String))
                {
                    this.ErrorTextBlock.Text = (String)value;
                }

                if (value.GetType() == typeof(Dictionary<String,String>))
                {
                    this.ErrorTextBlock.Text = ((Dictionary<String, String>)value).ToConcatString();
                }
            }
        }

        /// <summary>
        /// Shows the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        public void Show(String text)
        {
            ErrorTextBlock.Text = text;
            this.ShowDialog();
        }


        /// <summary>
        /// Shows the specified dict.
        /// </summary>
        /// <param name="dict">The dict.</param>
        public void Show(Dictionary<String,String> dict)
        {
            ErrorTextBlock.Text = dict.ToConcatString();
            this.ShowDialog();
        }

        private void OnClick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
